//
//  CameraScanVModel.swift
//  Scaner
//
//  Created by liyahao on 2025/4/8.
//

import Foundation
import Combine

final class HomeVModel: ObservableObject {
 
    @Published var models: [Model] = []
    @Published var recentModels: [WrpModel] = []
    
    init() {
        self.models = [
            Model(id: "1", icon: "document.viewfinder", title: "扫描", type: .docu),
            Model(id: "2", icon: "waveform.badge.microphone", title: "录音", type: .record),
            Model(id: "3", icon: "translate", title: "翻译", type: .tts),
            Model(id: "4", icon: "camera", title: "解题", type: .camera),
            Model(id: "5", icon: "speaker.wave.2", title: "文转音", type: .translate),
        ]
        
        self.recentModels = [
            WrpModel(model: Model(id: "1", icon: "document.viewfinder", title: "数学课堂", type: .docu), path: "", tsp: "2025-04-08 13:48"),
            WrpModel(model: Model(id: "2", icon: "document.viewfinder", title: "数学课堂", type: .docu), path: "", tsp: "2025-04-08 13:48"),
            WrpModel(model: Model(id: "3", icon: "document.viewfinder", title: "数学课堂", type: .docu), path: "", tsp: "2025-04-08 13:48"),
            WrpModel(model: Model(id: "4", icon: "document.viewfinder", title: "数学课堂", type: .docu), path: "", tsp: "2025-04-08 13:48"),
            WrpModel(model: Model(id: "5", icon: "document.viewfinder", title: "数学课堂", type: .docu), path: "", tsp: "2025-04-08 13:48"),
            WrpModel(model: Model(id: "6", icon: "document.viewfinder", title: "数学课堂", type: .docu), path: "", tsp: "2025-04-08 13:48"),
        ]
    }
    
    struct WrpModel: JSONable, Identifiable {
        var model: Model
        var path: String
        var tsp: String
        var id: String { model.id }
    }

    struct Model: JSONable, Identifiable {
        var id: String
        var icon: String
        var title: String
        var type: ItemType
    }

    enum ItemType: String, Codable {
        case docu, record, tts, camera, translate
    }
}

